#ifndef _MQTTMESSAGE_HEAD_H
#define _MQTTMESSAGE_HEAD_H
#include <mosquitto.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <memory>

using namespace std;

class MQTTMessage
{
public:
    MQTTMessage(const mosquitto_message *msg);
    int size() const;
    void *data() const;
    char *topic() const;
    int qos() const;
    ~MQTTMessage();
    class Message
    {
    public:
        //此处用到智能指针
        Message(const mosquitto_message *msg);
        ~Message();
        int size() const;
        void *data() const;
        char *topic() const;
        int qos() const;

    private:
        mosquitto_message message;
    };

private:
    mosquitto_message message;
    shared_ptr<Message> m_msg;
};

#endif